home *** CD-ROM | disk | FTP | other *** search
- /* Example 1.c
- This code follows the overview of gadgets doc
- included with this developer disk.
-
- Patrick Hager, Great Valley Products Inc.
- October 30, 1993
- */
- #include <stdio.h>
- #include "/global/userwindow.h"
- #include "/global/egslibraries.h"
-
- #include <egs/egsintui.h>
- #include <egs/clib/egsintui_protos.h>
- #include <egs/pragmas/egsintui_pragmas.h>
- #include <egs/egsgadbox.h>
- #include <egs/clib/egsgadbox_protos.h>
- #include <egs/pragmas/egsgadbox_pragmas.h>
-
-
- #define TESTING_ID 200
-
-
- struct UserInputWindow Example_Request;
-
- EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow);
- void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress);
-
- void main (void) {
-
- if (OpenEGSLibraries ()) {
- Init_UserWindow (&Example_Request, "Example Window",WINDOW_MODAL,NULL,
- NULL);
- Example_Request.Create = Create_Example;
- Example_Request.GadgetDown = GadgetDown_Example;
- Example_Request.IDCMPFlags = EI_iCLOSEWINDOW | EI_iSIZEVERIFY |
- EI_iNEWSIZE | EI_iGADGETDOWN;
- Example_Request.Flags = EI_SIZEBBOTTOM| EI_SIMPLE_REFRESH |
- EI_GIMMEZEROZERO;
- Example_Request.SysGadgets = (EI_WINDOWCLOSE)|(EI_WINDOWSIZE)|EI_WINDOWDRAG;
-
- if (Open_UserWindow (&Example_Request,-1,-1)) {
- Close_UserWindow (&Example_Request);
- }
- else
- printf ("Couldn't open my window!\n");
- }
- CloseEGSLibraries (); // after the bracket cause what if I opened 3 but
- // couldn't find the rest, still need to close the 3.
- }
-
- /*************************************
- PRIVATE: Create_Example.
- This routine is called by the UserWindow routines.
- It passes back a GadBoxPtr to the gadgets wanted.
- *************************************/
- EB_GadBoxPtr Create_Example (UserInputWindowPtr UserWindow) {
- EB_GadBoxPtr root;
- EB_GadContext gadcon;
-
- gadcon = UserWindow->GadCon;
-
- root = EB_CreateVertiBox (gadcon);
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 1",TESTING_ID,EB_FILL_ALL));
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 2",TESTING_ID+1,EB_FILL_ALL));
- EB_AddLastSon (root,EB_CreateTextAction (gadcon,"Gadget 3",TESTING_ID+2,EB_FILL_ALL));
-
-
- EB_AddLastSon (root,EB_CreateVertiFill (gadcon,0,0));
- return root;
- }
-
- /**************************************
- PRIVATE: GadgetDown_Example.
- This routine handles the gadget down events passed to the
- Example Control Window.
- **************************************/
- void GadgetDown_Example (UserInputWindowPtr UserWindow, EI_GadgetPtr iaddress) {
-
-
- switch (iaddress->GadgetID) {
- case TESTING_ID:
- printf ("You hit Top Gadget!\n");
- break;
- case TESTING_ID+1:
- printf ("You hit Middle Gadget!\n");
- break;
- case TESTING_ID+2:
- printf ("You hit Bottom Gadget!\n");
- break;
- }
- }